Skip to content

auth: base64url session cookie so proxies keep it - #4

Open
danctrl wants to merge 1 commit into
OpenStudy-dev:mainfrom
danctrl:fix/session-cookie-base64url
Open

danctrl wants to merge 1 commit into
OpenStudy-dev:mainfrom
danctrl:fix/session-cookie-base64url

Conversation

@danctrl

@danctrl danctrl commented Nov 29, 2026

Copy link
Copy Markdown

The session cookie value is the signed raw JSON payload, so it contains quotes and commas. Reverse proxies that re-parse the Cookie header with Go's net/http drop such values (e.g. NetBird's reverse proxy, netbirdio/netbird#7298), which logs users out right after sign-in.

Change: issue_session now signs base64url(JSON) without padding; optional_user decodes it and still accepts existing raw-JSON cookies and the legacy b"authed" cookie, so nobody is logged out by the update.

Testing: new test test_issued_cookie_is_proxy_safe_and_resolves (cookie value has no ", , or \, and resolves to the user); full suite 374 passed; ruff check app/ tests/ scripts/ clean. Running behind NetBird's proxy in production since 2026-11-28.

ruff format --check reports both touched files, but they were already unformatted upstream; I left formatting alone to keep the diff to the fix.

🤖 Generated with Claude Code

The session cookie value was the signed raw JSON payload, so it held
quotes and commas. Reverse proxies that re-parse the Cookie header with
Go's net/http (e.g. NetBird's reverse proxy, netbirdio/netbird#7298)
drop such values, which logged users out right after sign-in.

issue_session now signs base64url(JSON) without padding; optional_user
decodes it and still accepts existing raw-JSON cookies and the legacy
b"authed" cookie, so nobody is logged out by the update.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant